package day_2022_9_to_12.Day;

/**
 * @author haomin
 * @date 2022/09/04 10:44
 **/
public class Day2_2_Num6167_CheckDistances {
    public static void main(String[] args) {
        System.out.println(checkDistances("abaccb",new int[]{1,3,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));
    }

    public static boolean checkDistances(String s, int[] distance) {
        for(int i = 0; i < distance.length; ++i){
            int count = distance[i];
            char a = (char)(i+'a');
            String c = ""; c += a;
            if(!s.contains(c)) continue;
            int start = -1, end = -1;
            for(int j = 0; j < s.length(); ++j){
                if(a == s.charAt(j)) {
                    if (start == -1) start = j;
                    else end = j;
                }
            }
            if((end-start-1) != count) return false;
        }
        return true;
    }

}